
#include <ctime>
#include <iostream>
#include <fstream>

using namespace std;

void Sortirovka(int Mas[], int mas_len) {
while(mas_len--)  {
  bool bool_i = false;
  
  for(int i = 0; i < mas_len; i++) {
   if(Mas[i] > Mas[i + 1]){
    swap(Mas[i], Mas[i + 1]);
    bool_i = true;
   }
  } 

  if(bool_i == false) break;
}
}

void read_from_file(const char *filename, int a[], int length) {
    ifstream file(filename);

    for(int i=0; i < length; i++)
        file >> a[i];
}

int main()
{
    #define LEN 5000
    int a[LEN];

    read_from_file("m1_sorted.txt",a,LEN);
    unsigned int time_start =  clock();
    Sortirovka(a,LEN);
    unsigned int time_finish = clock();
    unsigned int time_all = time_finish - time_start;
    cout<<"m1_sorted " << time_all << " milliseconds \n";
    
    read_from_file("m2_reverse.txt",a,LEN);
    time_start =  clock();
    Sortirovka(a,LEN);
    time_finish = clock();
    time_all = time_finish - time_start;
    cout<<"m2_reverse " << time_all << " milliseconds \n";
    
    read_from_file("m3_shuffle.txt",a,LEN);
    time_start =  clock();
    Sortirovka(a,LEN);
    time_finish = clock();
    time_all = time_finish - time_start;
    cout<<"m3_shuffle " << time_all << " milliseconds \n";
    
    return 0;
}
